package com.carp.controller;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.carp.common.DBResult;
import com.carp.entity.CarpFile;
import com.carp.entity.CarpUser;
import com.carp.mapper.CarpUserMapper;
import com.carp.service.CarpFileService;
import com.carp.service.CarpUserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

@RestController
public class LoginController {

    @Resource
    private CarpUserService carpUserService;

    @Resource
    private CarpUserMapper carpUserMapper;

    /**
     * 登录login
     */
    @PostMapping("/login")
    public DBResult toLogin(@RequestBody CarpUser carpUser){
        return carpUserService.selectUser(carpUser);
    }

    /**
     * 修改用户信息
     */
    @PostMapping("/updateUser")
    public DBResult toUpdateUser(@RequestBody CarpUser carpUser){
        Boolean aBoolean = carpUserService.updateUser(carpUser);
        if (aBoolean){
            return DBResult.success("修改成功!");
        }
        return DBResult.error();
    }

    /**
     * 测试接口
     */
    @RequestMapping("/test")
    public DBResult toTest(){
        return DBResult.success("hello");
    }

}
